﻿using System;

namespace Be.Timvw.Framework.Domain.Effectivity
{
    /// <summary>
    /// Represents an element that changes over time. 
    /// It consists out of effectivities of that element that are effective in different periods.
    /// </summary>
    public interface ITemporal<T>
    {
        /// <summary>
        /// Modifies the element from the given date.
        /// </summary>
        /// <param name="element"></param>
        /// <param name="from"></param>
        /// <returns></returns>
        void Modify(T element, DateTime from);

        /// <summary>
        /// Gets the effectivity that is valid on the given date.
        /// </summary>
        /// <param name="validityDate">The validity date.</param>
        /// <returns></returns>
        IEffectivity<T> GetSnapshot(DateTime validityDate);

        /// <summary>
        /// Tries to get the effectivity that is valid on the given date.
        /// </summary>
        /// <param name="validityDate"></param>
        /// <param name="effectivity"></param>
        /// <returns></returns>
        bool TryGetSnapshot(DateTime validityDate, out IEffectivity<T> effectivity);
    }
}